<%--
  Created by IntelliJ IDEA.
  User: 86188
  Date: 2020/11/17
  Time: 1:58
  To change this template use File | Settings | File Templates.
--%>
<%@ include file="../common/IncludeTop.jsp"%>
<script src="js/cart.js" type="text/javascript"></script>


<div id="BackLink">
    <a href="main">Return to Main Menu</a>
</div>

<div id="Catalog">

    <div id="Cart">

        <h2>Shopping Cart</h2>

        <form action="viewCart" method="post">
            <table>
                <tr>
                    <th><b>Item ID</b></th>
                    <th><b>Product ID</b></th>
                    <th><b>Description</b></th>
                    <th><b>In Stock?</b></th>
                    <th><b>Quantity</b></th>
                    <th><b>List Price</b></th>
                    <th><b>Total Cost</b></th>
                    <th><b>Operation</b></th>
                </tr>

                <c:if test="${sessionScope.cart.numberOfItems == 0 || sessionScope.account == null}">
                    <tr>
                        <td colspan="8"><b>Your cart is empty.</b></td>
                    </tr>
                </c:if>

                <c:forEach var="cartItem" items="${sessionScope.cart.cartItems}">
                    <tr>
                        <td>
                            <a href="viewItem?itemId=${cartItem.item.itemId}">
                                    ${cartItem.item.itemId}
                            </a>
                        </td>
                        <td>
                                ${cartItem.item.product.productId}
                        </td>
                        <td>
                                ${cartItem.item.attribute1} ${cartItem.item.attribute2}
                                ${cartItem.item.attribute3} ${cartItem.item.attribute4}
                                ${cartItem.item.attribute5} ${cartItem.item.product.name}
                        </td>
                        <td>
                                ${cartItem.inStock}
                        </td>
                        <td>
                            <div style="width: 140px">

                                <button style="width: 32px; height: 32px; border: 2px red; float: left;"  class="decrease"  type="button">
                                </button>
                                    <%--                            <input type="text" name="${cartItem.item.itemId}" value="${cartItem.quantity}">--%>
                                    <%--                            <button>+</button>--%>
                                <input style="text-align: center; width: 60px; height: 35px; float: left;" type="text" value="1"  class="quantity"/>
                                <button style="width: 32px; height: 32px; border: 2px red; float: left;" class="increase" type="button">
                                </button>

                            </div>
                        </td>
                        <td class="listPrice">
                            <fmt:formatNumber  value="${cartItem.item.listPrice}" pattern="$#,##0.00" />
                        </td>
                        <td class="totalPrice">
                            <fmt:formatNumber value="${cartItem.total}" pattern="$#,##0.00" />
                        </td>
                        <td>
                            <a class="Button" href="removeItemFromCart?workingItemId=${cartItem.item.itemId}">
                                Remove
                            </a>
                        </td>
                    </tr>
                </c:forEach>
                <tr>
                    <td colspan="7" id="subTotal">Sub Total:
                        <fmt:formatNumber value="${sessionScope.cart.subTotal}" pattern="$#,##0.00" />
                    </td>
                </tr>
            </table>
        </form>
        <c:if test="${sessionScope.cart.numberOfItems > 0}">
            <a class="Button" href="viewOrderForm">Proceed to Checkout</a>
        </c:if>
    </div>

    <div id="Separator">&nbsp;</div>
</div>

<%@ include file="../common/IncludeButtom.jsp"%>